<template>
	<view class="content" v-if="start">
			<view class="nav">
				<first-nav :nav="nav"></first-nav>
			</view>
			<keep-alive>
				<page-swiper :current_city="current_city" swiper_view="主页"></page-swiper>
			</keep-alive>
			<tab v-if="tab_show"></tab>
	</view>
</template>

<script>
	import t from '../../common/helper.js';
	import FirstNav from '../../components/FirstNav.vue';
	import Tab from '../../components/Tab.vue';
	import PageSwiper from '../../components/PageSwiper.vue';
	
	
	export default {
		data() {
			return {
				start: false,
				nav: {
					text_left: '推荐',
					text_right: '同城',
					icon_name: 'icon-sousuo',
				},
				curpage: 1,
				tab_show: true,
				userId: '',
			}
		},
		components: {
			FirstNav,
			Tab,
			PageSwiper,
		},
		watch: {
			userId() {
				this.start = true;
			}
		},
		methods: {
			commentShow() {
				this.$bus.$on('commentShow',(res) => {
					this.tab_show = res;
				})
			}
		},
		created() {
			let user = '';
			uni.showLoading();
			//首次进入获取userId，此个人方法实属不太行，先用着
			let timer = setInterval(() => {
				user = uni.getStorageSync('user');
				if(user.length != 0) {
					clearInterval(timer);
					this.userId = uni.getStorageSync('user')[0].userId;
					this.commentShow();
				}
			},100);
		}
	}
</script>

<style lang="scss">
	.content {
		.nav {
			transition: all 1s;
		}
	}
</style>
